package cn.yangliu.nacos.comm.handler;

import java.util.Arrays;
import java.util.List;

import org.springframework.util.AntPathMatcher;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-02
 */
public interface ResultAdvice {

    /**
     * The Ignore urls.
     */
    List<String> IGNORE_URLS = Arrays.asList("/swagger-resources/**","/v2/api-docs");

    /**
     * current class instance's member.
     * The constant MATCHER.
     */
    AntPathMatcher MATCHER = new AntPathMatcher();

    /**
     * Ignore boolean.
     *
     * @param url the url
     * @return the boolean
     */
    default boolean ignore(String url) {
        for (String ignoreUrl : IGNORE_URLS) {
          if (MATCHER.match(ignoreUrl, url)){
              return false;
          }
        }
        return true;
    }

}
